package face.pay.web.mch.controller.info;

import face.pay.system.annotation.CurrentUser;
import face.pay.common.enterprise.service.IEnterpriseBaseService;
import face.pay.entity.EnterpriseInfo;
import face.pay.entity.UserInfo;
import face.pay.util.ResultMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Auther: zkj
 * @Date: 2019/7/11 10:51
 * @Description:商家信息管理
 */
@Slf4j
@Controller
@RequestMapping(value = "/enterprise_info")
public class
EnterpriseInfoController {

    @Autowired
    private IEnterpriseBaseService iEnterpriseBaseService;

    /**
     * @return
     */
    @RequestMapping("/index")
    public String manager(Model model, @CurrentUser UserInfo loginUser, Integer mchUserId) {
        mchUserId = mchUserId == null ? loginUser.getId() : mchUserId;
        EnterpriseInfo enterpriseInfo = this.iEnterpriseBaseService.getInfoByUserId(mchUserId);
        model.addAttribute("enterpriseInfo", enterpriseInfo);
        return "agency/enterprise/configure/configure";
    }


    @RequestMapping("/edit")
    @ResponseBody
    public ResultMessage editUser(@CurrentUser UserInfo loginUser, EnterpriseInfo enterpriseInfo) {
        return iEnterpriseBaseService.modifyInfo(enterpriseInfo, loginUser);
    }

}
